﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using IFRS.Web;
using System.Data;
using IFRS.DataAccess.DAL;
using IFRS.Models;
using IFRS_Global;

public partial class IFRS_WIN27_3V : PageBase
{
    #region "---------- Property -----------"

    private readonly SPR_RECLASSIFICATION dal_reclass = new SPR_RECLASSIFICATION();
    private Reclassification reclass = new Reclassification();

    #endregion

    #region "---------- Events -----------"

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!(Page.IsPostBack || Page.IsCallback))
        {
            this.ViewMenu();
            BindControlData();
            SetErrorMessage();
            BindData();
        }
        else
            ClientScript.RegisterHiddenField("isPostBack", "1");
    }

    protected void btnCANCEL_Click(object sender, EventArgs e)
    {
        Response.Redirect("~/IFRS/WIN27_1S.aspx");
    }

    #endregion

    #region "---------- Methods -----------"

    private void ViewMenu()
    {
        this.MenuTitleBar = Resources.ifrsResource.View + Resources.ifrsMenu.WIN27;
    }

    private void SetErrorMessage()
    {
    }

    private void BindControlData()
    {
        ddlSOURCE_DATA.SetData(DDL_TYPE.SourceData, "", true, false);
        ddlNEW_CLASSIFY.SetData(DDL_TYPE.NewClassify, "", true, false);

        SetControlReadOnly(form_control);
    }

    private void BindData()
    {
        if (Request.QueryString["id"] == null)
            return;

        int ID = Convert.ToInt32(Request.QueryString["id"].ToString());
        DataTable dtReclass = dal_reclass.SEARCH_BYID(ID);
        List<Reclassification> ReclassList = new List<Reclassification>();
        ConvertHelper.ConvertDataTableToObject(dtReclass, ReclassList);
        if (dtReclass.Rows.Count > 0)
        {
            hidReclassificationID.Value = ReclassList[0].ReclassificationID.ToString();
            txtTRANSACTION_DATE.Text = ReclassList[0].TransactionDate.DateToString();
            ddlSOURCE_DATA.SelectedValue = ReclassList[0].SourceDataID.IntToString();
            txtACCOUNT_NO.Text = ReclassList[0].AccountNo;
            ddlNEW_CLASSIFY.SelectedValue = ReclassList[0].NewClassifyID.IntToString();
            txtFAIRVALUE.Text = ReclassList[0].FairValue.DecimalToString();
        }
    }

    #endregion
}